<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">
	<!-- 组织机构树形 begin -->
	<div class="ui-layout-west">
		<div class="main-content">
			<div class="box box-main">
				<div class="box-header">
					<div class="box-title">
						<i class="fa icon-grid"></i> 组织机构
					</div>
					<div class="box-tools pull-right">
						<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
						<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
					</div>
				</div>
				<div class="ui-layout-content">
					<div id="tree" class="ztree"></div>
				</div>
			</div>
		</div>
	</div>
	<!-- 组织机构树形 end -->

    <div class="container-div ui-layout-center">
		<div class="row">
			<!-- 条件查询栏 begin -->
			<div class="col-sm-12 search-collapse">
				<form id="user-form">
					<input type="hidden" id="deptId" name="deptId">
					<input type="hidden" id="parentId" name="parentId">
					<div class="select-list">
						<ul>
							<li>
								名称型号：<input type="text" name="namePn"/>
							</li>
							<li>
								序列号：<input type="text" name="serialNo"/>
							</li>
							 <!-- 负责人 supervisorId TODO 暂时不做，目前想到的是用弹出层做选择，可做成多选的。 -->
							<li>
								报废审核状态：<select name="scrapaudit" th:with="type=${@dict.getType('equip_info_scrapaudit')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								高值设备：<select name="valueFlag" th:with="type=${@dict.getType('equip_info_value')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li class="select-time">
								<label>购置日期： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<!-- 条件查询栏 end -->
			<!-- 批量审核通过 导出 按钮 begin -->
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-danger btn-del disabled" onclick="scrapAuditPass(true)" shiro:hasPermission="equipment:scrapaudit:pass">
					<i class="fa fa-edit"></i> 普通设备报废通过
				</a>
				<a class="btn btn-warning btn-del disabled" onclick="scrapAuditPass(false)" shiro:hasPermission="equipment:scrapaudit:notpass">
					<i class="fa fa-remove"></i> 普通设备报废不通过
				</a>
				<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="equipment:audit:export">
					<i class="fa fa-download"></i> 全部导出
				</a>-->
			</div>
			<!-- 批量审核通过 导出 按钮 end -->
			<!-- 表格区，上述按钮包括在此区域内 begin -->
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
			<!-- 表格区，上述按钮包括在此区域内 end -->
		</div>
    </div>
    <div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
    <script th:inline="javascript">
        var detailFlag = [[${@permission.hasPermi('equipment:scrapaudit:detail')}]];
        var datas_scrapaudit = [[${@dict.getType('equip_info_scrapaudit')}]];
        var datas_value = [[${@dict.getType('equip_info_value')}]];
        var prefix = ctx + "equipment/scrapaudit";

        $(function() {
            $('body').layout({ west__size: 185 });
            queryEquipScrapauditList();
            queryDeptTree();
        });

        function queryEquipScrapauditList() {
            var options = {
                url: prefix + "/list",
                detailUrl: prefix + "/detail/{id}",
                sortName: "scrapTime",
                sortOrder: "desc",
                striped:true,
                modalName: "报废审核",
                search: false,
                showExport: false,
                uniqueId : 'equipId',
                columns: [{
                    checkbox: true,
                    formatter: function(value, row, index) {
                        if (row.scrapaudit != '0' || row.valueFlag != '0')
                            return {
                                disabled : true//设置不可用
                            };
                        return value;
                    }
                },
				{
					field : 'scrapaudit',
					title : '过审状态',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas_scrapaudit, value);
					}
				},
				{
					field : 'namePn',
					title : '名称型号'
				},
				{
					field : 'dept.deptName',
					title : '部门名称'
				},
				{
					field : 'serialNo', 
					title : '序列号' 
				},
				{
					field : 'scrapTime',
					title : '报废日期' ,
					sortable: true
				},
				{
					field : 'user.userName',
					title : '负责人' 
				},
				{
					field : 'buyTime', 
					title : '购置日期'
				},
				{
					field : 'totalPrice', 
					title : '总价格' 
				},
				{
					field : 'valueFlag', 
					title : '高值设备',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas_value, value);
                    }
				},
				{
					field : 'warranty', 
					title : '质保期(月)' 
				},
				{
					field : 'place', 
					title : '放置地点' 
				},
				{
					field : 'supportPhone', 
					title : '售后电话' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-warning btn-xs' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.equipId + '\')"><i class="fa fa-search"></i>详情</a> ');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        }

        function scrapAuditPass(flag) {
            if(flag) {//报废审核通过
                $.table._option.handleUrl = prefix + "/pass",
        		$.operate.handleAll('审核通过');

			} else {//报废审核不通过
                $.table._option.handleUrl = prefix + "/notpass",
                $.operate.handleAll('审核 不 通过')
			}
		}

        function queryDeptTree() {
            var url = ctx + "system/dept/treeData";
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                $("#deptId").val(treeNode.id);
                $("#parentId").val(treeNode.pId);
                $.table.search();
            }
        }

        $('#btnExpand').click(function() {
            $._tree.expandAll(true);
            $(this).hide();
            $('#btnCollapse').show();
        });

        $('#btnCollapse').click(function() {
            $._tree.expandAll(false);
            $(this).hide();
            $('#btnExpand').show();
        });

        $('#btnRefresh').click(function() {
            queryDeptTree();
        });

        /*用户管理-部门*/
        function dept() {
            var url = ctx + "system/dept";
            createMenuItem(url, "部门管理");
        }

    </script>
</body>
</html>